package com.mychart.entity.domain;

import lombok.Getter;

import java.util.HashMap;

@Getter
public class HttpRes extends HashMap<String,Object>{
    public static final String SUCCESS_CODE = "200";
    public static final String SUCCESS_MESSAGE = "操作成功";
    public static final String ERROR_CODE = "500";
    public static final String ERROR_MESSAGE = "操作失败";
    private HttpRes() {}
    public static HttpRes success() {
        return getInstance(SUCCESS_CODE,SUCCESS_MESSAGE);
    }
    public static HttpRes error() {
        return getInstance(ERROR_CODE,ERROR_MESSAGE);
    }
    public static HttpRes getInstance(String code, String message) {
        HttpRes res = new HttpRes();
        res.put("code",code);
        res.put("message",message);
        return res;
    }

    public void addParam(String key, Object value) {
        this.put(key,value);
    }
}
